package com.unittec.drainage.provider.auth.excel.export.impl;

import java.io.File;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.unittec.drainage.provider.entity.ExportTaskEntity;
import com.unittec.drainage.provider.excel.utils.ExcelRow;
import com.unittec.drainage.provider.excel.utils.IExcelExportConsumer;
import com.unittec.drainage.sdk.root.internal.exception.BusinessException;

/**
 * @Description:
 * @Author: wuxinwei
 * @CreateDate: 2019年12月4日10:48:55
 */
@Component
public class SimpleExportConsumer<T extends ExcelRow> implements IExcelExportConsumer<T> {

    public static final String TYPE_CLASS = "typeClass";

    @Override
    public File consume(ExportTaskEntity exportTask, Map<String, Object> paramMap) {
        String typeClassStr = (String)paramMap.get(TYPE_CLASS);
        try {
            Class<T> typeClass = (Class<T>)Class.forName(typeClassStr);
            return IExcelExportConsumer.super.consume(exportTask, paramMap, typeClass);
        } catch (ClassNotFoundException e) {
            throw new BusinessException(e);
        }
    }

}
